package ltesim.sdkManager.versionParser;

import java.io.File;

/**
 * @author xirka
 * SDKVersionParser Helper
 */
public class SDKVersionParser {

	/**
	 * Get the sdk version from a given path<br/>
	 * ex C:/foo/bar/sdk_1.2.3 will return 1.2.3<br/>
	 * change this method to set a different rule
	 * @param _fAbsPath
	 * @return sdk version
	 */
	public static String getVersion(String _fAbsPath) {
		String retval = "";
		File file = new File(_fAbsPath);
		if (file.exists()) {
			String folderName = file.getName();
			boolean bol = false;
			for (int i = 0; i < folderName.length(); i++) {
				char x = folderName.charAt(i);
				if (Character.isDigit(x)) {
					retval += x;
					bol = true;
				} else if ((x == '_' || x == '.' )&& bol) {
					retval += '.';
				}
			}
		}
		return retval;
	}

}
